//------------------------------------------------------------------------------ 
//  <copyright file="VideoFormats.h" company="Microsoft Corporation">
// The MIT License (MIT)
// 
// Copyright (c) 2014, Microsoft Corporation
// 
// Permission is hereby granted, free of charge, to any person obtaining a copy
//  of this software and associated documentation files (the "Software"), to deal
//  in the Software without restriction, including without limitation the rights
//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//  copies of the Software, and to permit persons to whom the Software is
//  furnished to do so, subject to the following conditions:
// 
// The above copyright notice and this permission notice shall be included in
//  all copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
//  THE SOFTWARE.
//  </copyright>
//------------------------------------------------------------------------------
#pragma once

#include "managed.h"

namespace Microsoft {
    namespace Robotics {
        namespace Vision {
            namespace Cameras {
				namespace Webcam {

/// <summary>
/// Forward declaration for video formats.
/// </summary>
ref class VideoFormats;

/// <summary>
/// Video format which stores associates between guids and names
/// </summary>
public ref class VideoFormat : IEquatable<VideoFormat ^>
{
internal:  

    static VideoFormat();

    /// <summary>
    /// Initializes a new instance of the <c>VideoFormat</c> class.
    /// </summary>
    ///<param name="guid">GUID of media type</param>
    ///<param name="name">FourCC of media type</param>
    VideoFormat(Guid guid, String^ name) : m_guid(guid),m_name(name)
    {
    };

private:
    /// <summary>
    /// Guid of media type
    /// </summary>
    Guid m_guid;

    /// <summary>
    /// FourCC of media type
    /// </summary>
    String^ m_name;

    static array<VideoFormat^>^ videoFormats;
public:

    /// <summary>
    /// Gets the Guid
    /// </summary>
    property System::Guid Guid
    {
        System::Guid get()
        {
            return m_guid;
        }
    }

    /// <summary>
    /// Gets the FourCC Name
    /// </summary>
    property String^ Name
    {
        String^ get()
        {
            return m_name;
        }
    }

    /// <summary>
    /// Returns true if obj is equal to this, false otherwise
    /// </summary>
    ///<param name="obj">The object to the compared</param>
    virtual bool Equals(Object ^obj) override;

    /// <summary>
    /// Returns true if obj is equal to this, false otherwise
    /// </summary>
    ///<param name="other">The VideoFormat to be compared</param>
    ///<returns>True if equal, false otherwise</returns>
    virtual bool Equals(VideoFormat ^other);

    /// <summary>
    /// Returns true if left is equal to right, false otherwise
    /// </summary>
    ///<param name="left">The first VideoFormat to be compared</param>
    ///<param name="right">The second VideoFormat to be compared</param>
    ///<returns>True if equal, false otherwise</returns>
    static bool operator ==(VideoFormat^ left, VideoFormat^ right);

    /// <summary>
    /// Returns true if left is not equal to right, false otherwise
    /// </summary>
    ///<param name="left">The first VideoFormat to be compared</param>
    ///<param name="right">The second VideoFormat to be compared</param>
    ///<returns>True if not equal, false otherwise</returns>
    static bool operator !=(VideoFormat^left, VideoFormat^ right);

    /// <summary>
    /// Returns the hash code corresponding to the video format.
    /// </summary>
    ///<returns>Hashcode</returns>
    virtual int GetHashCode() override;

    /// <summary>
    /// Creates a video format from the given guid
    /// </summary>
    ///<param name="guid">The guid for which video format needs to be constructed</param>
    ///<returns>video format from the given guid</returns>
    static VideoFormat^ FromGuid(System::Guid guid);

    /// <summary>
    /// Creates a video format from the given fourcc name
    /// </summary>
    ///<param name="guid">The fourcc name for which video format needs to be constructed</param>
    ///<returns>video format from the given fourcc name</returns>
    static VideoFormat^ FromName(String^ name);
};


/// <summary>
/// The video formats supported
/// </summary>
public ref class VideoFormats abstract sealed
{
public:

    /// <summary>
    /// Gets the YUY2 video format
    /// </summary>
    static property VideoFormat^ VideoFormatYUY2 {VideoFormat^ get();}    

    /// <summary>
    /// Gets the MJPG video format
    /// </summary>
    static property VideoFormat^ VideoFormatMJPG {VideoFormat^ get();}
};
}}}}}
